﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MicropleSoft.WmsApp.Library.ServiceFacade;

// ReSharper disable CheckNamespace
namespace MicropleSoft.WmsApp.Library.ServiceFacade 
// ReSharper restore CheckNamespace
{
    public partial class BaseDomainObject : IBaseDomainObject
    {
        public void AcceptChanges()
        {
            this.DomainObjectState = DomainEntityState.None;
        }

        public void AfterQueryFromServer()
        {
            this.PropertyChanged += BaseDomainObjectPropertyChanged;
        }

        private void BaseDomainObjectPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "DomainObjectState")
            {
                if (DomainObjectState != DomainEntityState.Added)
                {
                    DomainObjectState = DomainEntityState.Updated;
                }
            }
        }
    }
}
